<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of newsletter_m
 *
 * @author Gidaff_01
 */
class Newsletter_m extends Model {
    //put your code here
    function Newsletter_m() {
        parent::Model();
        $this->load->database();
    }

    function get_all_news($per_page, $offset){
        $this->db->select();
        $this->db->from('zoo_newsletter');
        $this->db->limit($per_page, $offset);
        $query = $this->db->get();
        return $query->result_array();
    }

    function count_all_news(){
        $this->db->select();
        $this->db->from('zoo_newsletter');
        $query = $this->db->get();
        return count($query->result_array());
    }

    function get_newsletter_detail($id){
        $this->db->select();
        $this->db->from('zoo_newsletter');
        $this->db->where('id',$id);
        $query = $this->db->get();
        return $query;
    }

    function update_newsletter($data,$id){
        return $this->db->update('zoo_newsletter',$data,array('id'=>$id));
    }

    function get_all_email(){
        $this->db->select('lehu_users.email,lehu_profiles.display_name');
        $this->db->from('lehu_users,lehu_profiles');
        $this->db->where('lehu_users.id = lehu_profiles.user_id');
        $query = $this->db->get();
        return $query->result_array();
    }

    function delete_newsletter($id){
        return $this->db->delete('zoo_newsletter',array('id'=>$id));
    }

    function ajouter_newsletter($data){
        return $this->db->insert('zoo_newsletter',$data);
    }
}
?>
